import java.util.Random;
import java.util.Scanner;
import java.util.Arrays;
public class test {
    public static int fac(int n){
        if(n==1){
            return 1;
        }
        return n*fac(n-1);
    }
    public static int fib(int n) {
        if (n == 1 || n == 2) {
            return 1;
        }
        return fib(n - 1) + fib(n - 2);
    }
    public static int fib2(int n){
        int f1 =1;
        int f2=1;
        int f3=0;
        for (int i=3;i<=n;i++){
            f3=f1+f2;
            f1=f2;
            f2=f3;
        }
        return f3;
    }

    public static void main(String[] args) {
        System.out.println(fib2(10));
        System.out.println(fib(40));
    }
    public static void main12(String[] args) {
        Random random = new Random();
        int randNum = random.nextInt(100);//[0,100)
        System.out.println(randNum);
        Scanner scan =new Scanner(System.in);
        while(true){
            System.out.println("请输入你要猜的数字:");
            int num = scan.nextInt();
            if(num<randNum){
                System.out.println("小了");
            }else if(num==randNum){
                System.out.println("找到了");
                break;
            }else{
                System.out.println("大了");
            }
        }
    }
    public static void main11(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("读入一个整型");
        int age =scan.nextInt();
        System.out.println(age);
        scan.nextLine();
        System.out.println("读入一个字符串:");
        String str=scan.nextLine();
        System.out.println(str);
        System.out.println("读入一个小数:");
        float f=scan.nextFloat();
        System.out.println(f);
    }
    public static void main10(String[] args) {
        int n=7;
        int count =0;
        while(n !=0){
            n=n&(n-1);
            count++;
        }
        System.out.println(count);
    }
    //求公约数
    public static void main9(String[] args) {
        int a=24;
        int b=18;
        int c= a % b;
        while(c!=0){
            a=b;
            b=c;
            c=a % b;
        }
        System.out.println(b);
    }
    public static void main8(String[] args) {
        //求分数1/1-1/1+1/2……1/100
        double sum=0;
        int flg=1;
        for (int i=1;i<=100;i++){
            sum+=sum+1.0/i+flg;
            flg=-flg;
        }
        System.out.println(sum);
    }
    public static void main7(String[] args) {
        //X型图案
       Scanner in =new Scanner(System.in);
       //注意hasnext和hasNextline 的区别
        while(in.hasNextInt()){
            int a=in.nextInt();
            for (int i=0;i<a;i++){
                for (int j=0;j<a;j++){
                    if(i==j||i+j==(a-1)){
                        System.out.print("*");
                    }else{
                        System.out.print(" ");
                    }
                }
                System.out.println();
        }
        }
    }
    public static void main6(String[] args) {
        //九九乘法表
        for (int i=1;i<=9;i++){
            for (int j=1;j<=i;j++){
                System.out.println(i+"*"+j+"="+(i*j));
            }
            System.out.println(" ");
        }
    }
    public static void main5(String[] args) {
        //求水仙花数
        for (int i=0;i<=99999;i++){
            int count =0;
            int tmp=i;
            while(tmp!=0){
                count++;
                tmp/=10;
            }
            tmp=i;
            int sum=0;
            while(tmp!=0){
                sum += Math.pow(tmp%10,count);
                tmp/=10;
            }
            if(sum==i){
                System.out.println(i);
            }
        }
    }
    public static void main4(String[] args) {
        //求1-100之间的含9的数
        int count=0;
        for (int i=1;i<=100;i++){
            if (i%10==9){
                count++;
            }
            if(i/10==9){
                count++;
            }
        }
        System.out.println(count);
    }
    public static void main3(String[] args) {
        //求2-100之间的素数
        int i=0;
        for (i=2;i<=100;i++){
            boolean n= false;
            int j=0;
            for ( j=2;j<=i-1;j++){
                if(i%j==0){
                    System.out.println(i+"不是素数");
                    n=true;
                    break;
                }
                if(n==false){
                    System.out.println(i+"是素数" );
                }
            }
        }
    }
    public static void main2(String[] args) {
        int n=7;
        int i=2;
        for (;i<=Math.sqrt(n);i++){
            if(n%i==0){
                break;
            }
        }
        if(i>Math.sqrt(n)){
            System.out.println(n +"是素数");
        }
    }
    public static void main1(String [] args){
        System.out.println("Hello World");
        System.out.println("中文");
    }
}
